let path = window.location.href;
Pid = path.split("?")[1].split("=")[1];
$(function () {
    $.ajax({
        url: "/details/getBlogById",
        type: "GET",
        data: {"pid": Pid},
        success: function (data) {
            $(".article-cont").append("<div class='title'>\n" +
                "                                <h3>" + data.title + "</h3>\n" +
                "                                <p class='cont-info'><span class='data'>" + formatDate(data.createTime) + "</span><span class='types'>"+data.blogType.typeName+"</span>\n" +
                "                                </p>\n" +
                "                            </div>\n" +
                "                            <p>" + data.content + "</p>\n" +
                "                            <div class=\"btn-box\">\n" +
                "                                <button class='layui-btn layui-btn-primary'>点赞👍</button>\n" +
                "                                <button class='layui-btn layui-btn-primary'>比心♥</button>\n" +
                "                            </div>")
        }
    })
})


//时间戳转换方法    date:时间戳数字
function formatDate(date) {
    var date = new Date(date);
    var YY = date.getFullYear() + '-';
    var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
    var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
    return YY + MM + DD + " " + hh + mm + ss;
}